package org.czl.leetcode4;

public class l3255 {
    class Solution {
        public int[] resultsArray(int[] nums, int k) {
            int n = nums.length;
            int[] len = new int[n];
            len[0] = 1;
            for(int i = 1; i < n; i++){
                if(nums[i] - 1 == nums[i - 1]){
                    len[i] = len[i - 1] + 1;
                }else{
                    len[i] = 1;
                }
            }

            int[] res = new int[n - k + 1];
            for(int i = k - 1; i < n; i++){
                if(len[i] >= k) res[i - k + 1] = nums[i];
                else res[i - k + 1] = -1;
            }

            return res;
        }
    }
}
